<?php

Yii::import('application.models._base.BaseAuthKey');

class AuthKey extends BaseAuthKey
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
         public function InsertAuthKey($user_id) {
        $this->setAttribute('user_id', $user_id);
        $this->setAttribute('auth_key', guid());
        $this->setAttribute('expires_on', getExpireTime());
        $this->save();
        return true;
    }
    public function rules() {
		return array(
			array('user_id', 'required'),
			array('user_id, expires_on', 'numerical', 'integerOnly'=>true),
			array('auth_key', 'length', 'max'=>45),
			array('auth_key, expires_on', 'default', 'setOnEmpty' => true, 'value' => null),
			array('id, user_id, auth_key, expires_on', 'safe', 'on'=>'search'),
		);
	}

    
}